Skip to content

merge config prop passed to BentoProvider with the one passed at creation #999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 8, 2025

Conversation

veej
Copy link
Member

@veej veej commented Apr 4, 2025

No description provided.

@veej veej requested review from gabro and Copilot April 4, 2025 08:40
@veej veej changed the title merge config prop passed to BentoProvider with the one passed at crea… merge config prop passed to BentoProvider with the one passed at creation Apr 4, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

packages/bento-design-system/test/createBentoProvider.test.tsx:5

  • [nitpick] Consider renaming the test suite from 'createBentoProviders' to 'createBentoProvider' to match the actual function name and avoid potential confusion.
describe("createBentoProviders", () => {

<DefaultMessagesContext.Provider value={{ defaultMessages }}>
<BentoConfigProvider value={props.config ?? config}>
<DefaultMessagesContext.Provider value={defaultMessagesValue}>
<BentoConfigProvider value={deepmerge(config, props.config) as BentoConfig}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how much overhead deepmerge adds when one object is undefined, but since BentoConfigProvider internally does a deepmerge too, maybe we can do the merge only if there's a props.config?

Suggested change
<BentoConfigProvider value={deepmerge(config, props.config) as BentoConfig}>
<BentoConfigProvider value={props.config ? deepmerge(config, props.config) as BentoConfig : config}>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thank you 🙏

@veej veej merged commit 21392ca into main Apr 8, 2025
11 checks passed
@veej veej deleted the parent-config branch April 8, 2025 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants